#pragma once
#include <QGraphicsLineItem>
#include "Item.h"

class NodeInPort;
class NodeOutPort;
class AbstractManager;
class xMappingTree;
class xLink;
class QMenu;
class QAction;

class LineItem :
	public Item, public QGraphicsLineItem
{
	Q_OBJECT

public:
	LineItem( xMappingTree* ,NodeInPort* ,NodeOutPort* ,AbstractManager* );
	~LineItem(void);
	NodeInPort*  getInport();
	NodeOutPort* getOutport();
	xLink* getLink();
	void updatePosition();
	void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
	void removeFromScene();

public slots:
	void remove();

protected:
	QVariant itemChange(GraphicsItemChange ,const QVariant &);
	void contextMenuEvent(QGraphicsSceneContextMenuEvent* );
	QPainterPath shape () const;
	QRectF boundingRect() const;
	void keyPressEvent ( QKeyEvent* );

private:
	NodeInPort*  _inport;
	NodeOutPort* _outport;
	xLink* _link;
	QMenu* _contextMenu;
	QAction* _deleteAction;
	void createActions();
	void initMenu();
};
